package studio7.servlet;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import studio7.dao.InstrumentoDAO;
//import studio7.dao.SalaDAO;
import studio7.exception.DAOException;
import studio7.modelo.Instrumento;
//import studio7.modelo.Sala;

/**
 * Servlet implementation class registrarSala
 */
@WebServlet("/registrarInstrumentoServlet")
public class registrarInstrumentoServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public registrarInstrumentoServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		Instrumento instrumento = new Instrumento();
		// instrumento.setCodigoInstrumento(Integer.parseInt(request.getParameter("codigoInstrumento")));
		// instrumento.setNombreInstrumento(request.getParameter("nombreInstrumento"));
		instrumento.setMarcaInstrumento(request.getParameter("txtMarca"));
		instrumento.setTipoInstrumento(request.getParameter("txtTipo"));
		instrumento.setModeloInstrumento(request.getParameter("txtModelo"));
		instrumento.setCaracteristicaInstrumento(request.getParameter("txtCaracteristicas"));
		
		InstrumentoDAO dao = new InstrumentoDAO();
		try {
			dao.insertar(instrumento);
		} catch (DAOException e) {
			System.out.println(e.toString());
		}
		RequestDispatcher rd = request.getRequestDispatcher("registrarInstrumento.jsp");
		rd.forward(request, response);
	}
		
	}


